package qlsl.androiddesign.adapter.commonadapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseExpandableListAdapter;
import qlsl.androiddesign.entity.otherentity.Category.RowsBean;
import qlsl.androiddesign.entity.otherentity.ShoopChildList;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.TextView;

import com.qlsl.androiddesign.kuaiwa.R;

public class ShoppingExpAdapter extends BaseExpandableListAdapter {

	public ShoppingExpAdapter(BaseActivity activity,
			ExpandableListView listView,
			List<? extends Map<String, ?>> groupList,
			List<? extends List<? extends Map<String, ?>>> childList) {
		super(activity, listView, groupList, childList);
	}

	@SuppressWarnings("unchecked")
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_shopping_group);

		ImageView iv_icon = getView(convertView, R.id.vehicle_fragment_item_img);
		TextView tv_text = getView(convertView,
				R.id.vehicle_fragment_item_title);
		TextView tv_time = getView(convertView,
				R.id.vehicle_fragment_item_address);

		HashMap<String, RowsBean> map = (HashMap<String, RowsBean>) getGroup(groupPosition);
		RowsBean item = map.get("group");

		ImageUtils.rect(activity, item.getPhoto(), iv_icon);
		tv_text.setText(item.getSuppliertype());
		tv_time.setText(item.getSuppliertype());

		return convertView;

	}

	@SuppressWarnings("unchecked")
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_shopping_child);
		TextView tv_content = getView(convertView, R.id.tv_content);

		HashMap<String, ShoopChildList.RowsBean> map = (HashMap<String, ShoopChildList.RowsBean>) getChild(
				groupPosition, childPosition);
		ShoopChildList.RowsBean item = map.get("child");

		tv_content.setText(item.getSubtiertype());

		return convertView;
	}

}